<template>
  <div class="btn" @click="btn" :class="type">
    <!-- 插槽 自定义内容-->
    <slot>按钮</slot>
  </div>
</template>

<script>
export default {
  props: {
    type: String,
  },
  methods: {
    btn() {
      //触发父组件的自定义事件
      this.$emit("click");
    },
  },
};
</script>

<style lang="less" scoped>
.btn {
  width: 318px;
  height: 48px;
  background-color: #ccc;
  color: #666;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 20px;
  border-radius: 24px;
  margin: 20px auto;
}
.primary {
  border: 1px solid green;
  background-color: green;
  color: #fff;
}
.danger {
  border: 1px solid red;
  background-color: red;
  color: #fff;
}
</style>